﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using TCC.ControleFluxoDeCaixa.Apresentacao.ViewModels;
using TCC.ControleFluxoDeCaixa.Model.Fluxo;

namespace TCC.ControleFluxoDeCaixa.Apresentacao.Views
{
    /// <summary>
    /// Interaction logic for LancamentoCadastroWindow.xaml
    /// </summary>
    public partial class LancamentoListaWindow : Window
    {
        public LancamentoListaWindow()
        {
            InitializeComponent();

            ViewModel.Finished += Close;
            ViewModel.MessageSent += s => MessageBox.Show(s);
        }

        private Lancamento _lancamentoEscolhido;
        public static Lancamento Escolher()
        {
            var wnd = new LancamentoListaWindow {SelecionarButton = {Visibility = Visibility.Visible}};
            wnd.ShowDialog();
            return wnd._lancamentoEscolhido;
        }

        private void SelecionarButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedLancamento == null) return;
            _lancamentoEscolhido = ViewModel.SelectedLancamento;
            Close();
        }
    }
}
